// 模拟API服务，实际应用中会连接到Django后端
export const fetchMarketData = () => {
  return new Promise((resolve) => {
    // 模拟API延迟
    setTimeout(() => {
      const mockData = [
        { id: 1, name: '腾讯控股', code: '00700.HK', price: 345.60, change: 1.2, volume: 24567 },
        { id: 2, name: '阿里巴巴', code: '09988.HK', price: 112.80, change: -0.8, volume: 18765 },
        { id: 3, name: '贵州茅台', code: '600519.SH', price: 1789.50, change: 2.5, volume: 8765 },
        { id: 4, name: '宁德时代', code: '300750.SZ', price: 456.30, change: 3.1, volume: 34567 },
        { id: 5, name: '美团-W', code: '03690.HK', price: 156.40, change: -1.2, volume: 19876 },
        { id: 6, name: '招商银行', code: '600036.SH', price: 38.75, change: 0.6, volume: 54321 },
        { id: 7, name: '比亚迪', code: '002594.SZ', price: 268.90, change: 2.8, volume: 28765 },
        { id: 8, name: '中国平安', code: '601318.SH', price: 48.20, change: -0.4, volume: 39876 }
      ];
      resolve(mockData);
    }, 800);
  });
};

// 实际应用中连接到Django的示例
/*
import axios from 'axios';

const API_BASE_URL = 'http://localhost:8000/api';

export const fetchMarketData = async () => {
  try {
    const response = await axios.get(`${API_BASE_URL}/market-data/`);
    return response.data;
  } catch (error) {
    console.error('Error fetching market data:', error);
    throw error;
  }
};

export const saveStrategy = async (strategyData) => {
  try {
    const response = await axios.post(`${API_BASE_URL}/strategies/`, strategyData);
    return response.data;
  } catch (error) {
    console.error('Error saving strategy:', error);
    throw error;
  }
};
*/